Skip to content

fix(mcp): fix SSE transport host binding and remove invalid sse_params kwarg#17

Open
eddiefleurent wants to merge 1 commit intoHKUDS:mainfrom
eddiefleurent:fix/mcp-sse-host-port
Open

fix(mcp): fix SSE transport host binding and remove invalid sse_params kwarg#17
eddiefleurent wants to merge 1 commit intoHKUDS:mainfrom
eddiefleurent:fix/mcp-sse-host-port

Conversation

@eddiefleurent
Copy link
Copy Markdown

Problem

Two bugs prevent the MCP SSE transport from working:

1. TypeError on startup

mcp.run() is called with sse_params={"port": args.port} but the mcp library's FastMCP.run() does not accept a sse_params keyword argument, causing an immediate crash:

TypeError: FastMCP.run() got an unexpected keyword argument 'sse_params'

2. SSE server binds to 127.0.0.1 (localhost only)

FastMCP defaults to host="127.0.0.1", so when running SSE transport the server is unreachable from any other machine — making remote MCP clients (Claude Code, Cursor, etc.) unable to connect.

Fix

  • Pass host and port directly to the FastMCP constructor, defaulting to 0.0.0.0:8080 with overrides via FASTMCP_HOST / FASTMCP_PORT env vars
  • Remove the invalid sse_params kwarg from mcp.run()

Note: the --port CLI arg was already a no-op since FastMCP is instantiated at module level before args are parsed. Users should use FASTMCP_PORT env var to configure the port.

Usage after fix

# default port 8080, all interfaces
python mcp_server.py --transport sse

# custom port
FASTMCP_PORT=8091 python mcp_server.py --transport sse

# localhost only
FASTMCP_HOST=127.0.0.1 python mcp_server.py --transport sse

…s kwarg

- FastMCP defaults to 127.0.0.1 which prevents remote connections when
  running SSE transport. Default to 0.0.0.0 and allow override via
  FASTMCP_HOST / FASTMCP_PORT env vars.
- mcp.run() does not accept sse_params kwarg (raises TypeError). Remove it.
  The --port arg was always a no-op since FastMCP is instantiated at module
  level before args are parsed; use FASTMCP_PORT env var instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant